﻿using System;
using System.Collections.Generic;
using System.Reflection;
using Abp.Application.Services;
using Abp.AutoMapper;
using Abp.Modules;
using Abp.Reflection.Extensions;
using AutoMapper;
using Hicap.AuthorizationServer.Core;
using Hicap.AuthorizationServer.Sys.DTO.AuthObjectRoleRelateds.LTMAutoMapper;
using Hicap.AuthorizationServer.Sys.DTO.AuthObjects.LTMAutoMapper;
using Hicap.AuthorizationServer.Sys.DTO.Comapnys.LTMAutoMapper;
using Hicap.AuthorizationServer.Sys.DTO.Roles.LTMAutoMapper;
using Hicap.AuthorizationServer.Sys.DTO.UserRoleRelateds.LTMAutoMapper;
using Hicap.AuthorizationServer.Sys.DTO.Users.LTMAutoMapper;

namespace Hicap.AuthorizationServer
{
    [DependsOn(
        typeof(AuthorizationServerCoreModule),
        typeof(AbpAutoMapperModule))]
    public class AuthorizationServerApplicationModule : AbpModule
    {
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(typeof(AuthorizationServerApplicationModule).GetAssembly());
        }

        public override void PreInitialize()
        {
            base.PreInitialize();
            Configuration.Modules.AbpAutoMapper().Configurators.AddRange(
                new List<Action<IMapperConfigurationExpression>>()
                {
                    CustomerUserMapper.CreateMappings,
                    CustomerRoleMapper.CreateMappings,
                    CustomerAuthObjectMapper.CreateMappings,
                    CustomerAuthObjectRoleRelatedMapper.CreateMappings,
                    CustomerUserRoleRelatedMapper.CreateMappings,
                    CompanyMapper.CreateMappings
                });
        }
    }
}